#include "S_3_FanControl_doGet.h"
#include "mi_iid_define.h"
#include "property_decoder.h"
#include "main.h"
#include "section_define.h"



/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 0(Auto), 1(Level1), 2(Level2), 3(Level3), 4(Level4), 5(Level5), 6(Level6), 7(Level7), 8(Level8)
 */
static void P_3_2_FanLevel_doGet(property_operation_t *o)
{
//	static uint8_t WindSpeed = 0;
#if 	PROPERTY_TYPE
	InDoorBusReg PbsReg = {0};
	PbsReg.V8 = GetPbsRegValue(0x0C);																		//风机档位
//	if(PbsReg.BIT1.bit7)
	{
		property_value_new_integer(&o->value,PbsReg.BIT1.bit0_6);
	}		
	
//	WindSpeed = AirGetWindSpeedLevel();
//	if(WindSpeed == WINDSPEEDAUTO)
//	{
//		property_value_new_integer(&o->value,0);
//	}
//	else
//	{
//		property_value_new_integer(&o->value,WindSpeed);
//	}
#else	
    o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 8; // TODO: 这里需要读到属性真正的值
#endif	
	
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_3_3_HorizontalSwing_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	InDoorBusReg PbsReg = {0};
	PbsReg.V8 = GetPbsRegValue(0x0002);																	//左右摆风		
	if(PbsReg.BIT.bit6)																									
		property_value_new_boolean(&o->value,true);
	else
		property_value_new_boolean(&o->value,false);
	
//	if(AirGetLeftRightSwingMode() == FULLSCAN_ON)
//	{
//		property_value_new_boolean(&o->value,true);
//	}
//	else if(AirGetLeftRightSwingMode() == FULLSCAN_OFF)
//	{
//		property_value_new_boolean(&o->value,false);
//	}
#else	
    o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif	
	
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_3_4_VerticalSwing_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	InDoorBusReg PbsReg = {0};
	PbsReg.V8 = GetPbsRegValue(0x0002);																	//上下摆风
	if(PbsReg.BIT.bit4)																									
		property_value_new_boolean(&o->value,true);																					
	else
		property_value_new_boolean(&o->value,false);
		
//	if(AirGetUpDownSwingMode() == FULLSCAN_ON)
//	{
//		property_value_new_boolean(&o->value,true);
//	}
//	else if(AirGetUpDownSwingMode() == FULLSCAN_OFF)
//	{
//		property_value_new_boolean(&o->value,false);
//	}
#else	
    o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif	
	
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_3_24_WindSensation_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
//	property_value_new_boolean(&o->value,true);
#else	
    o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif	
}



/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 0(Off), 1(Top Rating), 2(Freeze Top), 3(Rating Left), 4(Freeze Down), 5(Lower Rating)
 */
static void P_3_25_VerticalPosition_doGet(property_operation_t *o)
{
//	static uint8_t SwingMode = 0;
#if 	PROPERTY_TYPE
	InDoorBusReg PbsReg = {0};
	PbsReg.V8 = GetPbsRegValue(0x0E);																		//整体上下定格
	property_value_new_integer(&o->value,PbsReg.BIT1.bit0_6);	
		
//	property_value_new_integer(&o->value,AirGetUpDownSwingMode());
#else	
    o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 3; // TODO: 这里需要读到属性真正的值
#endif	
	
}

/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 0(Off), 1(Left Sweep), 2(Freeze Left), 3(Middle Sweep), 4(Freeze Right), 5(Right Sweep)
 */
static void P_3_26_HorizontalPosition_doGet(property_operation_t *o)
{
//	static uint8_t SwingMode = 0;
#if 	PROPERTY_TYPE
	InDoorBusReg PbsReg = {0};
	PbsReg.V8 = GetPbsRegValue(0x04);																		//整体左右定格

	property_value_new_integer(&o->value,PbsReg.BIT1.bit0_6);				

		
//	property_value_new_integer(&o->value,AirGetLeftRightSwingMode());

	
#else	
    o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 4; // TODO: 这里需要读到属性真正的值
#endif
}

/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 0(Off), 1(Sky Curtain Wind), 2(Carpet Wind)
 */
static void P_3_11_WindDirection_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1 = {0};	
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x000D);
//	if(RegSection1.BIT1.bit7)
	{
		property_value_new_integer(&o->value,RegSection1.BIT1.bit0_6);
	}
	
#else	
    o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 1; // TODO: 这里需要读到属性真正的值
#endif	
	
}

void S_3_FanControl_doGet(property_operation_t *o)
{
    switch (o->piid)
    {
        case PIID_3_2_FanLevel:
            P_3_2_FanLevel_doGet(o);
            break;

        case PIID_3_3_HorizontalSwing:
            P_3_3_HorizontalSwing_doGet(o);
            break;

        case PIID_3_4_VerticalSwing:
            P_3_4_VerticalSwing_doGet(o);
            break;
		case PIID_3_24_WindSensation:
            P_3_24_WindSensation_doGet(o);
            break;
		
        case PIID_3_25_VerticalPosition:
            P_3_25_VerticalPosition_doGet(o);
            break;

        case PIID_3_26_HorizontalPosition:
            P_3_26_HorizontalPosition_doGet(o);
            break;

        case PIID_3_11_WindDirection:
            P_3_11_WindDirection_doGet(o);
            break;

        default:
            o->code = OPERATION_ERROR_VALUE;
            break;
    }
}
